# Visualization Toolkit (VTK) Tcl package configuration.

package ifneeded vtkinit {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@} {
  namespace eval ::vtk::init {
    proc load_library_package {libName libPath {libPrefix {@VTK_TCL_LIBNAME_PREFIX@}}} {
      set libExt [info sharedlibextension]
      set currentDirectory [pwd]
      set libFile [file join $libPath "$libPrefix$libName$libExt"]
      if {[catch "cd {$libPath}; load {$libFile}" errorMessage]} {
        puts $errorMessage
      }
      cd $currentDirectory
    }
    proc require_package {name {version {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@}}} {
      if {[catch "package require -exact $name $version" errorMessage]} {
        puts $errorMessage
        return 0
      } else {
        return 1
      }
    }
    set version {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@}
    set kits {}
    foreach kit { base Common Filtering IO Imaging Graphics
                  @VTK_TCL_RENDERING_CONFIG@ @VTK_TCL_VOLUMERENDERING_CONFIG@
                  @VTK_TCL_HYBRID_CONFIG@ @VTK_TCL_WIDGETS_CONFIG@
                  @VTK_TCL_PARALLEL_CONFIG@ @VTK_TCL_GEOVIS_CONFIG@ 
                  @VTK_TCL_INFOVIS_CONFIG@ @VTK_TCL_VIEWS_CONFIG@
                  @VTK_TCL_CHARTS_CONFIG@ @VTK_TCL_CHEMISTRY_CONFIG@
                  @VTK_TCL_TEXTANALYSIS_CONFIG@} {
      lappend kits [string tolower "${kit}"]
    }
  }
  package provide vtkinit {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@}
}

foreach kit { Common Filtering IO Imaging Graphics
              @VTK_TCL_RENDERING_CONFIG@ @VTK_TCL_VOLUMERENDERING_CONFIG@
              @VTK_TCL_HYBRID_CONFIG@ @VTK_TCL_WIDGETS_CONFIG@
              @VTK_TCL_PARALLEL_CONFIG@ @VTK_TCL_GEOVIS_CONFIG@ 
              @VTK_TCL_INFOVIS_CONFIG@ @VTK_TCL_VIEWS_CONFIG@
              @VTK_TCL_CHARTS_CONFIG@ @VTK_TCL_CHEMISTRY_CONFIG@
              @VTK_TCL_TEXTANALYSIS_CONFIG@} {
  package ifneeded "vtk${kit}TCL" {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@} "
    package require -exact vtkinit {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@}
    ::vtk::init::load_library_package {vtk${kit}TCL} {@VTK_TCL_LIBRARY_DIR@}
  "
  package ifneeded "vtk[string tolower ${kit}]" {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@} "
    package require -exact vtkinit {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@}
    if {\[catch {source \[file join {@VTK_TCL_SCRIPT_DIR@} {vtk[string tolower ${kit}]} {vtk[string tolower ${kit}].tcl}\]} errorMessage\]} {
      puts \$errorMessage
    }
  "
}

foreach src {vtk vtkbase vtkinteraction vtktesting} {
  package ifneeded ${src} {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@} "
    package require -exact vtkinit {@VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@}
    if {\[catch {source \[file join {@VTK_TCL_SCRIPT_DIR@} {$src} {$src.tcl}\]} errorMessage\]} {
      puts \$errorMessage
    }
  "
}
